package student.list.updateStudent;

import com.mysql.MysqlMethod;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URLDecoder;

@WebServlet("/student4")
public class UpdateStudentServlet extends HttpServlet {
    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //在doPUt中要用流的方法获取前端传过来的参数
        BufferedReader reader = req.getReader();
        String studentId = reader.readLine();
        reader.close();//关闭流
        String str1 = URLDecoder.decode(studentId,"utf-8");//将获取的数据进行转码
        String[] str =  MysqlMethod.split02(str1);//将获取的字符串进行拆分得到数据
        //将获取到String类型的数据转为Interget类型
        Integer strage = Integer.valueOf(str[0]);
        Integer strclassId = Integer.valueOf(str[1]);
        Integer strstudentId = Integer.valueOf(str[8]);
        //调用方法进行修改
        MysqlMethod.update01(strage,strclassId,str[2],str[3],str[4],str[5],str[6],str[7],strstudentId,str[9]);
    }

}
